<template>
  <div>
    <h1>欢迎光临 vue开发收银系统的水果店</h1>
    <h2>苹果10&yen;/斤,折扣 8折</h2>
    请输入你要购买的斤数<input type="number" v-model="num" />
    <br />
    <button @click="buy">结账买单~</button>
    <br />
    结账单:总价:{{ sum }}元,折后价:{{ after }}元,省了{{ save }}元
  </div>
</template>

<script>
export default {
  data() {
    return {
      num: 0,
      sum: 0,
      after:0,
      save:0,
    };
  },
  methods: {
    buy() {
      this.sum = this.num * 10;
      this.after = this.num * (10*0.8);
      this.save=this.num*(10*0.2);
    },
  },
};
</script>

<style>
</style>
